﻿using Microsoft.AspNet.SignalR;
using System.Threading.Tasks;

namespace GuideAPI
{
    public class SampleHub : Hub
    {
        public override Task OnConnected()
        {
            return Clients.All.joined(GetAuthInfo());
        }

        private object GetAuthInfo()
        {
            var user = Context.User;
            return new
            {
                IsAuthenticated = user.Identity.IsAuthenticated,
                IsAdmin = user.IsInRole("Admin"),
                UserName = user.Identity.Name
            };
        }
    }
}